package com.gy.ai.agent.listener;

import com.gy.ai.agent.core.BaseResponse;
import com.gy.ai.agent.core.ReqContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public interface StreamRespListener {

    Logger logger = LoggerFactory.getLogger(StreamRespListener.class);

    default void onStart(ReqContext context) {
    }

    void onMessage(ReqContext context, BaseResponse response);

    default void onStop(ReqContext context) {
    }

    default void onFailure(ReqContext context, Throwable throwable) {
        if (throwable != null) {
            logger.error(throwable.toString(), throwable);
        }
    }
}
